package com.cardbaobao.cardbabyclient.ui.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.model.RepayRecord;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerAdapter;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonRecyclerHolder;
import com.cardbaobao.cardbabyclient.utils.ImageLoaderUtil;
import com.cardbaobao.cardbabyclient.utils.URLUtil;

import java.text.DecimalFormat;

/**
 * Description: 信用卡还款记录
 * Created by FHW
 * on 2017/11/14
 */

public class CreditRepayRecordRcAdapter extends CommonRecyclerAdapter<RepayRecord.RepayRecordsListsBean> {

    public CreditRepayRecordRcAdapter(Context context) {
        super(context, null, R.layout.item_credit_repay_record);
    }

    @Override
    public void convert(final CommonRecyclerHolder holder, final RepayRecord.RepayRecordsListsBean item) {

        ImageLoaderUtil.displayImage(URLUtil.CBB_IMG_URL + item.getPicture(), (ImageView) holder.getView(R.id.iv_pic));
        String cardId = item.getCredit_card_no();
        holder.setTextViewText(R.id.tv_bank_name, item.getCard_type_name() + "尾号(" + cardId.substring(cardId.length() - 4, cardId.length()) + ")");
        holder.setTextViewText(R.id.tv_time, item.getRepayTime());
        if (!item.getRepayment_amount().equals("")) {
            DecimalFormat df = new DecimalFormat("#0.00");
            holder.setTextViewText(R.id.tv_money, df.format(Double.parseDouble(item.getRepayment_amount())));
        }

        TextView tv_statue = holder.getView(R.id.tv_statue);
        TextView tv_money = holder.getView(R.id.tv_money);
        tv_money.setTextColor(mContext.getResources().getColor(R.color.color_222222));
        tv_statue.setTextColor(mContext.getResources().getColor(R.color.color_222222));
        switch (item.getState()) {
            case 1:
                holder.setTextViewText(R.id.tv_statue, "还款成功");
                break;
            case 2:
                holder.setTextViewText(R.id.tv_statue, "还款失败");
                break;
            case 3:
                holder.setTextViewText(R.id.tv_statue, "还款中");
                tv_statue.setTextColor(mContext.getResources().getColor(R.color.color_ff7373));
                break;
            case 4:
                holder.setTextViewText(R.id.tv_statue, "退款成功");
                break;
            case 5:
                holder.setTextViewText(R.id.tv_statue, "退款失败");
                tv_money.setTextColor(mContext.getResources().getColor(R.color.color_999999));
                tv_statue.setTextColor(mContext.getResources().getColor(R.color.color_AFAFAF));
                break;
            case 6:
                holder.setTextViewText(R.id.tv_statue, "退款中");
                break;
            default:
                break;
        }

    }

}
